package com.ruoyi.web.controller.mall.mallInvoiceUser.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.web.controller.mall.mallInvoiceUser.domain.MallInvoiceUser;
import com.ruoyi.web.controller.mall.mallInvoiceUser.service.IMallInvoiceUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 用户发票抬头信息Controller
 * 
 * @author ruoyi
 * @date 2021-01-18
 */
@RestController
@RequestMapping("/mall/mallInvoiceUser")
public class MallInvoiceUserController extends BaseController
{
    @Autowired
    private IMallInvoiceUserService mallInvoiceUserService;

    /**
     * 查询用户发票抬头信息列表
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(@RequestBody Map<String,Object> map)
    {
        startPage();
        List<Map<String,Object>> list = mallInvoiceUserService.selectMallInvoiceUserList(map);
        return getDataTable(list);
    }

    /**
     * 根据订单id获取开票信息
     */
//    @PreAuthorize("@ss.hasPermi('system:notice:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        Map<String,Object> map = mallInvoiceUserService.selectMallInvoiceUserById(id);
        if (map==null){
            return AjaxResult.error("该订单未申请开票");
        }
        return AjaxResult.success(map);
    }

    /**
     * 新增保存用户发票抬头信息
     */
//    @Log(title = "用户发票抬头信息", businessType = BusinessType.INSERT)
//    @PostMapping("/add")
//    public AjaxResult addSave(MallInvoiceUser mallInvoiceUser)
//    {
//        return toAjax(mallInvoiceUserService.insertMallInvoiceUser(mallInvoiceUser));
//    }


    /**
     * 修改保存用户发票抬头信息
     */
//    @Log(title = "用户发票抬头信息", businessType = BusinessType.UPDATE)
//    @PostMapping("/edit")
//    public AjaxResult editSave(MallInvoiceUser mallInvoiceUser)
//    {
//        return toAjax(mallInvoiceUserService.updateMallInvoiceUser(mallInvoiceUser));
//    }

}
